@extends('shop_admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    订单管理
    <small>订单列表</small>
    <small>订单详情</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 控制面板</a></li>
    <li ><a href="/shop_admin/order">订单列表</a></li>
    <li class="active">订单详情</li>
  </ol>
</section>

    <!-- Main content -->
    <section class="content">

      <!-- title row -->
      <div class="row">
        <div class="col-xs-12">

          <h2 class="page-header">
            <i class="fa fa-globe"></i> {{$order['order_sn']}}
            <a href=" @if(empty($back_url)){{route('shop_admin.order.index')}}@else {{@$back_url}}@endif" type="button" class="btn btn-success btn-xs pull-right">
              <i class="icon  glyphicon glyphicon glyphicon-menu-left"></i> 返回
            </a>
          </h2>
        </div>
        <!-- /.col -->
      </div>

      <div class="callout {{ $order->order_status==4 ? 'callout-success':($order->order_status==2?'callout-warning':($order->order_status==3?'callout-info':'callout-danger')) }}">
        <?php $orderStatusArr = ['0'=>'状态', '1'=>'待支付','2'=>'待发货','3'=>'已发货','4'=>'已完成','5'=>'已取消'];?>
        <?php if ($order->type==1) $orderStatusArr[3] = '海关处理';?>
        <p>
          <b>订单类型:</b> @if(@$order->order_type) e贸易 @else 普通 @endif
        </p>
        <p>
          <b>订单时间:</b> {{$order->add_time}}
        </p>
        <p>
          <b>订单状态:</b> {{$orderStatusArr[$order->order_status]}}&nbsp;@if(@$order->push_tarrif==1)<b>[业务单据状态:<font id="custom_status">正在获取状态..</font>&nbsp;&nbsp;核放单据状态:<font id="custom_status_2">正在获取状态..</font>]</b>@endif
          @if ($order->order_status==2)
            <!-- <button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal" style="margin-top: -4px;margin-left: 10px;">
              <i class="fa fa-credit-card"></i> 发货
            </button> -->
          @endif
          @if ($order->order_status==3)
          <button id="print" type="button" class="btn btn-success" style="margin-top: -4px;margin-left: 10px;">
            <i class="fa fa-print"></i> 打印快递单
          </button>
          @endif
        </p>
        @if ($order->order_status>=2&&$order->order_status!=5)
          <p>
            <b>支付方式:</b> {{$order->pay_type}} <br>
            <b>支付时间:</b> {{$order->pay_time}} <br>
            <b>支付流水:</b> {{$order->pay_num}} <br>
            @if(@$order->pay_push!=1)
              <b>支付单推送状态:</b> 待推送
            @endif
          </p>
        @endif
        @if ($order->order_status>=3&&$order->order_status!=5)
          <p>
            <b>配送方式:</b>

            <?php
                switch ($order->shipping_type) {

                  case 'eto':
                    echo '申通快递';
                    break;

                  case 'yto':
                    echo '圆通快递';
                    break;
                }

            ?>
            <br>
            <b>配送时间:</b> {{$order->shipping_time}} <br>
            <b>运单号:</b> {{$order->shipping_num}}
          </p>
        @endif
        @if ($order->order_type&&$order->order_status!=5)

          <p>
            <b>推关状态:</b>
            <?php
                switch (@$pushTarrif->push_tarrif_status) {
                  case '1':
                    echo '未推送';
                    break;
                  case '2':
                    echo '已推送';
                    break;
                  case '3':
                    echo '已取消';
                    break;
                  case '4':
                    echo '推关失败';
                    break;
              }
            ?>
            <br>
            @if(@$order->push_tarrif==1)
              <b>批次号:</b> ZYFT{{date('Ymd',strtotime($order->shipping_time))}}<?php if(date('H',strtotime($order->shipping_time))>=12) echo '2'; else echo '1'; ?>
              <br>
            @endif
            @if ($order->push_tarrif)
              <b>推关时间:</b> {{$order->push_tarrif_time}}
            @endif

          </p>
        @endif

      </div>

      <div class="row">

        <div class="col-md-4">
          <div class="box box-default">
            <div class="box-header with-border">
              <i class="fa fa-user"></i>
              <h3 class="box-title">用户信息</h3>
            </div>
            <div class="box-body" style="min-height: 100px;">

              <address>
                <strong>{{$userInfo->user_name}}</strong><br>
                手机: {{$userInfo->phone}}<br>
                Email: {{$userInfo->email}}<br>
                最后登录时间：{{$userInfo->last_login_time}}<br>
                最后登录ip：{{$userInfo->last_login_ip}}
              </address>
            </div>
          </div>
        </div>
        <!-- /.col-md-4 -->

        <div class="col-md-4">
          <div class="J-address-info box box-default">
            <div class="box-header with-border">
              <i class="fa fa-map-marker"></i>
              <h3 class="box-title">{{ trans('order.receiving_address') }}</h3>
              <div class="pull-right box-tools">
                <button type="button" class="J-edit btn btn-default btn-sm" data-toggle="tooltip" title="修改" >
                  <i class="fa fa-pencil"></i>
                </button>
              </div>
            </div>
            <div class="box-body" style="min-height: 100px;">
              <p><span class="J-name">{{$order->consignee}}</span> <span class="J-mobile">{{$order->mobile}}</span></p>
              <p class="J-idCard">{{$order->id_card}}</p>
              <p>
                <span class="J-province">{{$order->province}}</span>
                <span class="J-city">{{$order->city}}</span>
                <span class="J-district">{{$order->district}}</span>
                <span class="J-address">{{$order->address}}</span>
              </p>
              <p>邮编：</p>
              <p>备注：{{$order->order_message}}</p>
            </div>
          </div>
        </div>
        <!-- /.col-md-4 -->

        <div class="col-md-4">
          <div class="box box-default">
            <div class="box-header with-border">
              <i class="fa fa-user"></i>
              <h3 class="box-title">{{ trans('order.invoice') }}</h3>
            </div>
            <div class="box-body" style="min-height: 100px;">

            </div>
          </div>
        </div>
        <!-- /.col-md-4 -->

      </div>

      <div class="row">

        <div class="col-md-8">
          <div class="box box-default">
            <div class="box-header with-border">
              <i class="fa fa-list"></i>
              <h3 class="box-title">商品列表</h3>

              @if ($order->order_status==3)
                <div class="box-tools">
                  <div class="input-group input-group-sm" style="width: 80px;">
                    <div class="input-group-btn">
                      <button id="printGoods" type="submit" class="btn btn-success"><i class="fa fa-print"></i> 打印货单</button>
                    </div>
                  </div>
                </div>
              @endif

            </div>
            <div class="box-body" style="min-height: 200px;">
              <table class="table table-striped">
                <thead>
                <tr>
                  <th>货号</th>
                  <th>名称</th>
                  <th>价格</th>
                  <th>数量</th>
                  <th>小计</th>
                </tr>
                </thead>
                <tbody>
                @foreach($order->orderGoods as $goods)
                  <tr>
                    <td>{{$goods->goods_sn}}</td>
                    <td>{{$goods->goods_name}}</td>
                    <td>{{$goods->shop_price}}</td>
                    <td>{{$goods->buy_number}}</td>
                    <td>{{number_format($goods->shop_price*$goods->buy_number,2)}}</td>
                  </tr>
                @endforeach
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <!-- /.col-md-6 -->

        <div class="col-md-4">
          <div class="box box-default">
            <div class="box-header with-border">
              <i class="fa fa-cny"></i>
              <h3 class="box-title">{{ trans('order.amount_due') }} </h3>
            </div>
            <div class="box-body" style="min-height: 200px;">
              <table class="table table-hover">
                <tr>
                  <th style="width:50%">{{ trans('order.Subtotal') }}:</th>
                  <td>{{number_format($order->order_price,2)}}</td>
                </tr>
                <tr>
                  <th>税金:</th>
                  <td>{{number_format($order->order_tariff_fee,2)}}</td>
                </tr>
                <tr>
                  <th>优惠券:</th>
                  <td>-{{number_format($order->coupon_price,2)}}</td>
                </tr>
                <tr>
                  <th>{{ trans('order.Postages') }}:</th>
                  <td>{{number_format($order->shipping_fee,2)}}</td>
                </tr>
                <tr>
                  <th>{{ trans('order.Total_price') }}:</th>
                  <td>{{number_format($order->pay_price?$order->pay_price:($order->order_price+$order->order_tariff_fee+$order->shipping_fee),2)}}</td>
                </tr>
              </table>
            </div>
          </div>
        </div>
        <!-- /.col-md-6 -->

      </div>

    </section>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">发货</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          @if ($order->order_type==0)
          <div class="col-xs-3">
            <div class="form-group">
              <div class="input-group">
                {!! Form::select('time',$shippingList,@$_GET['time'],array('class'=>'form-control','placeholder'=>'物流','id'=>'shipping_type'))!!}
              </div>
            </div>
          </div>
          <div class="col-xs-9">
            <div id="shipping_nu_form" class="form-group">
              <div class="input-group">
                {!! Form::text('shipping_num',@$_GET['time'],array('class'=>'form-control','placeholder'=>'物流单号','id'=>'shipping_nu'))!!}
              </div>
            </div>
          </div>
            @else
            <div class="col-xs-9">
              确认发货么?
            </div>
          @endif
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button id="shippingBtn" type="button" class="btn btn-primary">点击发货</button>
      </div>
    </div>
  </div>
</div>


<script type="text/html" id="printTpl">
  <!--打印部分-->
  <div class="print-box">

    <!--上联 申通派件站存-->
    <div class="top-box">
      <!--logo和条形码-->
      <div class="logo-code">
        <div class="no-print logo">
          <img src="" alt="logo">
        </div>
        <div class="code">
          <img class="js-barcode" data-num="{{$order->shipping_num}}" data-type="1" alt="条形码">
          <p class="num">{{$order->shipping_num}}</p>
        </div>
      </div>

      <table class="top-table table-brd">

        <!--大号收货地址-->
        <tr class="to-address">
          <td style="height: 17mm;" colspan="3">
            <strong>TO:<span>{{$order->province}} {{$order->city}}{{$order->district}}</span></strong>
          </td>
        </tr>

        <!--收件人-->
        <tr class="addressee">
          <td class="label text-tc"><span>收件人</span></td>
          <td style="height: 18mm;" colspan="2">
              <p>收件人：{{$order->consignee}}</p>
              <p>收件地址：{{$order->province}}{{$order->city}}{{$order->district}}{{$order->address}}</p>
              <p>电话：{{$order->mobile}}</p>
          </td>
        </tr>
        <!--发件人-->
        <tr class="consignor">
          <td class="label text-tc" rowspan="2"><span>发件人</span></td>
          <td style="height: 14mm;" rowspan="2">
              <p>阿福易购</p>
              @if($order->order_type==1) <p>地址：河南保税物流中心</p> @endif
          </td>
          <td>
            <div class="max-h-6mm">品名：阿福易购</div>
          </td>
        </tr>
        <tr class="consignor">
          <td>
            <span>出库：{{$order->shipping_time}}</span>
          </td>
        </tr>

        <!--订单号-->
        <tr class="order-num">
          <td style="height: 7mm;" colspan="3">
            <span>订单号：</span>
            <img class="js-barcode" data-num="{{$order['order_sn']}}" alt="条形码">
            <span class="code-num">{{$order['order_sn']}}</span>
          </td>
        </tr>

        <!--签收-->
        <tr>
          <td class="w-50" colspan="2">
            <div style="height: 14mm;">签收前请确认商品包装完好，没有划痕、破损等表面质量问题，签收即代表确认完好。</div>
          </td>
          <td class="w-50">
            <span>收件人签名：</span>
            <div class="sign-time">
              <span class="fn-mr20">年</span>
              <span class="fn-mr20">月</span>
              <span class="fn-mr20">日</span>
            </div>
          </td>
        </tr>
      </table>

    </div>

    <!--下联 收件人存-->
    <div class="bottom-box">
      <table class="table-brd bottom-table">
        <tr>
          <td style="height: 13mm;">
            <div class="addressee">
              <p>
                <span class="fn-mr20">收件人：{{$order->consignee}}</span>
                <span>电话：{{$order->mobile}}</span>
              </p>
              <p>
                <span class="fn-mr20">收件地址：{{$order->province}} {{$order->city}}{{$order->district}}{{$order->address}}</span>
                <span>出库：{{$order->shipping_time}}</span>
              </p>
            </div>
          </td>
        </tr>
        <tr>
          <td style="height: 7mm;">
            <p>
              <span class="fn-mr16">发件人：阿福易购</span>
              <span class="fn-mr16">T:400-181-0068</span>
              <span>总件数：{{$order->total_goods_number}}</span>
            </p>
          </td>
        </tr>
        <tr class="goods-list">
          <td style="height: 22mm;">
            <div class="list-">
            @foreach($order->orderGoods as $goods)
                <span class="fn-fl w-50">{{$goods->goods_sn}} *{{$goods->buy_number}}</span>
             @endforeach
            </div>

          </td>
        </tr>
        <tr>
          <td>
            <div class="logo-code">
              <div class="no-print logo">
                <img src="" alt="logo">
              </div>
              <div class="code">
                <img class="js-barcode" data-num="{{$order->shipping_num}}" alt="条形码">
                <p class="num">{{$order->shipping_num}}</p>
              </div>
            </div>
          </td>
        </tr>
      </table>
    </div>

  </div>
  <!--end/打印部分-->

</script>
<script type="text/html" id="printTpl2">
  <div class="print-wrap">
    <div class="print-head">
      <ul class="cols-3">
        <li class="col">
          <img  class="logo no-print" src="{{ asset ("/images/logo.jpg") }}." style="width: 224px;height: 66px;" alt="">
        </li>
        <li class="col tc">
          <h1 class="name">阿福易购-购物清单</h1>
          <h2 class="sub-name">http://www.afuyigou.com</h2>
        </li>
        <li class="col">
          <p class="rb">客服电话：400-181-0068</p>
        </li>
        <li class="clear"></li>
      </ul>
      <div class="order-num">
        <span class="mr20">订单编号：{{$order->order_sn}}</span>
        <span class="mr50">订单生成时间：{{$order->add_time}}</span>
        <span class="mr20">

{{--
            @if($order->shipping_type=='eto') 申通快递-运单号： @else {{$order->shipping_type.'-运单号：'}} @endif {{$order->shipping_num}}
--}}


            <?php
                switch ($order->shipping_type) {

                  case 'eto':
                    echo '申通';
                    break;

                  case 'yto':
                    echo '圆通';
                    break;
                }

            ?>

            </span>
      </div>
    </div>

    <table class="goods-table">
      <tr>
        <th class="code">条形码</th>
        <th style="min-width: 16mm;">商品编号</th>
        <th style="min-width: 20mm;">商铺</th>
        <th>商品名称</th>
        <th style="min-width: 12mm;">单价</th>
        <th style="width: 16mm;">贸易类别</th>
        <th style="width: 10mm;">数量</th>
        <th style="min-width: 12mm;">价格</th>
      </tr>
      @foreach($order->orderGoods as $goods)

        <tr>
          <td class="code">
            @if(!empty($goods->goods_id))
                <?php
                //获取商品详细信息，为了获得条形码
                $goodsDetail=$goods_detail->where('goods_id','=',$goods->goods_id)->first();

                ?>
                @if(@$goodsDetail->goods_bar_code)
                  <img src="" class="js-barcode code-img" data-num="{{@$goodsDetail->goods_bar_code}}" alt="">
                  <p style="margin-top: 1px;">{{@$goodsDetail->goods_bar_code}}</p>
                  @else
                  <div class="code-img">无</div>
                @endif
            @endif
          </td>
          <td>{{$goods->goods_sn}}</td>
          <td>{{$shop->find($goods->shop_id)->shop_name}}</td>
          <td class="goods-name">{{$goods->goods_name}}</td>
          <td>{{$goods->shop_price}}</td>
          <td>@if($goods->type)E贸易@else一般贸易@endif</td>
          <td>{{$goods->buy_number}}</td>
          <td>{{number_format($goods->shop_price*$goods->buy_number,2)}}</td>
        </tr>
      @endforeach

    </table>
    <div class="print-foot">
      <p class="sum tr">
        <span class="mr20">合计</span>
        <span class="mr20">{{$order->total_goods_number}}件</span>
        <span>{{number_format($order->order_price,2)}}</span>
      </p>
      <div class="addressee">
        <p>
          <span class="mr50">收货人：{{$order->consignee}}</span>
          <span>联系电话：{{$order->mobile}}</span>
        </p>
        <p>
          <span>收货地址：{{$order->province}} {{$order->city}}{{$order->district}}{{$order->address}}</span>
        </p>
      </div>
    </div>

  </div>
</script>

<script id="formTpl" type="text/html">
  <form method="post" action="/shop_admin/order/update_address/{{$order->order_id}}" class="js-form form-horizontal" style="width: 100%;overflow: hidden;">
    <div class="ajax-form">
      <div class="form-group" style="margin-top: 10px;">
        <label class="col-sm-3 control-label"><em class="text-color-6">*</em>所在地区：</label>
        <div class='col-sm-2' style="padding-right: 0;">
          <input class="form-control" type="text" name="province" value="${province}" placeholder="省" required data-msg-required="请填写" maxlength="10" data-msg-maxlength="小于10个字">
        </div>
        <div class='col-sm-3' style="padding-right: 0;">
          <input class="form-control" type="text" name="city" value="${city}" placeholder="市" required data-msg-required="请填写" maxlength="10" data-msg-maxlength="小于20个字">
        </div>
        <div class='col-sm-3'>
          <input class="form-control" type="text" name="district" value="${district}" placeholder="区" required data-msg-required="请填写" maxlength="10" data-msg-maxlength="小于20个字">
        </div>
      </div>

      <div class="form-group">
        <label class="col-sm-3 control-label"><em class="text-color-6">*</em>详细地址：</label>
        <div class='col-sm-8'>
          <input id="detailAddress" class="form-control" type="text" name="address" value="${address}" placeholder="无需重复填写省市区，小于75个字" required data-msg-required="请填写详细地址" maxlength="75" data-msg-maxlength="小于75个字">
        </div>
      </div>

      <div class="form-group">
        <label class="col-sm-3 control-label"><em class="text-color-6">*</em>收货人名称：</label>
        <div class="col-sm-8">
          <input id="consignee" class="form-control" type="text" name="consignee" value="${consignee}" placeholder="请使用真实姓名，长度不超过12个字" required data-msg-required="请填写收货人" maxlength="75" data-msg-maxlength="小于12个字">
        </div>
      </div>
      <li class="form-group">
        <label class="col-sm-3 control-label"><em class="text-color-6">*</em>身份证号码：</label>
        <div class="col-sm-8">
          <input class="form-control" name="id_card" type="text" value="${id_card}" placeholder="请填写收货人本人的真实身份证号码 " required data-msg-required="请填写身份证" data-rule-idcard="true" >
        </div>
      </li>
      <div class="form-group">
        <label class="col-sm-3 control-label"><em class="text-color-6">*</em>手机号码：</label>
        <div class="col-sm-8">
          <input id="mobile" class="form-control" type="text" name="mobile" value="${mobile}" placeholder="请填写常用手机号" required data-msg-required="请填写手机号" data-rule-mobile="true">
        </div>
      </div>

      <div class="form-group bl-form-btns">
        <label class="sr-only">提交：</label>
        <div class="col-sm-8 col-sm-offset-3">
          <button class="btn btn-primary btn-save" type="submit" style="margin-right: 10px;">保存收货地址</button>
          <button class="btn btn-nostyle btn-cancel" type="button">取消</button>
        </div>
      </div>
    </div>
  </form>
</script>

<link rel="stylesheet" href="{{ asset ("/dist/css/sto-express.css") }}" media="print">
<link rel="stylesheet" href="{{ asset ("/dist/css/goods-list-express.css") }}" media="print">

<!--打印/二维码-->
<script src="{{ asset ("/dist/js/jquery.barCodePrint.min.js") }}"></script>

<!--地址插件-->
<script src="{{ asset ("/dist/js/layer/layer.js") }}"></script>
<script src="{{ asset ("/dist/js/jquery.plugin.min.js") }}"></script>
<script src="{{ asset ("/dist/js/jquery.validation.js") }}"></script>

<script type="text/javascript">
  //地址
  var addressInfo=$('.J-address-info'),

      nameSpan=$('.J-name',addressInfo),
      mobileSpan=$('.J-mobile',addressInfo),
      provinceSpan=$('.J-province',addressInfo),
      citySpan=$('.J-city',addressInfo),
      districtSpan=$('.J-district',addressInfo),
      addressSpan=$('.J-address',addressInfo),
      idCardSpan=$('.J-idCard',addressInfo);

  var linkageSel;


  //添加地址
  addressInfo.on('click','.J-edit',function(){
    var formTpl=$('#formTpl').html();

    //获取数据
    var addData={
      'province':provinceSpan.text(),
      'city':citySpan.text(),
      'district':districtSpan.text(),
      'address':addressSpan.text(),
      'consignee':nameSpan.text(),
      'mobile':mobileSpan.text(),
      'id_card':idCardSpan.text()
    };

    formTpl=tools.htmlTemplate(formTpl,addData,true);

    //弹出窗口
    layer.open({
      title:'编辑收货地址',
      type: 1,
      skin: 'layui-layer-rim', //加上边框
      area: '640px', //宽
      content: formTpl,
      success: function(layero, index){//layero--当前层DOM,index--当前层索引

        //地区选择实例化
        var jsForm=$('.js-form',layero);

        //表单验证
        jsForm.validate({
          errorClass:'text-red',
          submitHandler:function(form){
            var btn=jsForm.find('.btn-save');

            btn.addClass('disabled').prop('disabled',true).text('提交中...');
            tools.log(jsForm.serialize());
            $.ajax({
              url:form.action,
              type:'post',
              dataType:'json',
              data:jsForm.serialize(),
              success:function(res){
                if(res.status){
                  tools.log(jsForm.serializeArray());
                  var data={},formData=jsForm.serializeArray();
                  for(var i=0;i<formData.length;i++){
                    data[formData[i].name]=formData[i].value;
                  }

                  //渲染页面并赋值
                  nameSpan.text(data.consignee);
                  mobileSpan.text(data.mobile);
                  provinceSpan.text(data.province);
                  citySpan.text(data.city);
                  districtSpan.text(data.district);
                  addressSpan.text(data.address);
                  idCardSpan.text(data.id_card);

                  btn.removeClass('disabled').prop('disabled',false).text('保存收货地址');
                  layer.close(index);//关闭弹层

                }
              },
              error:function(error){
                btn.removeClass('disabled').prop('disabled',false).text('保存收货地址');
              }
            });
          }
        });

        //取消事件
        jsForm.on('click','.btn-cancel',function(){
          layer.close(index);
        });
      }
    });
  });

</script>

<script type="text/javascript">

  $('#shippingBtn').click(function(e){

    var btn = $(this);

    var shipping_type = $("#shipping_type").val();
    var shipping_num  =$('#shipping_nu').val();

    if (shipping_num==''){

      $('#shipping_nu_form').addClass('has-error');
      return false;
    }
    var data = {
      'shipping_type':shipping_type,
       'shipping_num':shipping_num
    };
    btn.attr('正在发货..');

    btn.addClass('disabled');

    $.ajax({
      url:'/admin/order/deliver/'+'{{$order->order_id}}',
      type:'post',
      data:data,
      dataType:'json',
      success:function(res){
        btn.removeClass('disabled');
        btn.val('点击发货');

        if (res.status=='success'){

          window.location.reload();
        }else{
          alert(res.message);
        }

      },
      error:function(){
        btn.removeClass('disabled');
        btn.val('点击发货');
      }

    });


  });


  @if(@$order->push_tarrif==1)
  $(document).ready(function(){

    $.ajax({
      url:'/admin/order/custom_status/'+'{{$order->order_id}}',
      type:'get',
      dataType:'json',
      success:function(res){

      if (res.out){
        $('#custom_status').html(res.out.distStatus+'-'+res.out.distStatusTime);
        $('#custom_status_2').html(res.out.status+'-'+res.out.statusTime);

      }else{
        $('#custom_status').html('暂无');
        $('#custom_status_2').html('暂无');

      }

      },
      error:function(){

      }

    });
  });
  @endif


  $('#pushBtn').click(function(e){

    var btn = $(this);


    btn.attr('正在推送..');

    btn.addClass('disabled');

    $.ajax({
      url:'/admin/order/push/'+'{{$order->order_id}}',
      type:'post',
      dataType:'json',
      success:function(res){

        btn.removeClass('disabled');
        btn.val('点击推送');


        if (res.status=='success'){

          window.location.reload();
        }else{
          alert(res.message);
        }

      },
      error:function(){
        btn.removeClass('disabled');
        btn.val('点击推送');
      }

    });


  });


  //打印订单
  $('#print').on('click',function(){
    var tpl=$('#printTpl').html();
    var jqObj=$(tpl);

    jqObj.find('.js-barcode').each(function(){
      var that=$(this),num=that.data('num');
      if(num=='') return false;

      that.JsBarcode(num+'');
    });

    //打印
    jqObj.jqprint();
  });

  //打印货单
  $('#printGoods').on('click',function(){

    var tpl=$('#printTpl2').html();
    var jqObj=$(tpl);

    jqObj.find('.js-barcode').each(function(){
      var that=$(this),num=that.data('num');
      if(num=='') return false;

      that.JsBarcode(num+'');
    });

    //打印
    jqObj.jqprint();
  });





</script>




@endsection